<?php
namespace Home\Controller;
use Think\Controller;
class AccountController extends CommonController {

	public function ajaxUpdatePwd(){
		if($this->checkLogin()==false){
			$response['msg'] = '尚未登陆';
			$response['toLogin'] = 1;
			$response['rsc'] = C('RESPONSE.FAILED');
			$this->ajaxReturn($response);
		}
		$user_id = $this->uId();
		$old_pwd = I('old_pwd');
		$new_pwd = I('new_pwd');
		$re_new_pwd = I('re_new_pwd');
		if($new_pwd!=$re_new_pwd){
			$response['msg'] = '两次新密码输入不一致';
			$response['rsc'] = C('RESPONSE.FAILED');
			$this->ajaxReturn($response);
		}
		$userSrv = D('UserInfo');
		$user_info = $userSrv->where("user_id = '".$user_id."'")->find();
		if($user_info['password']!=$old_pwd){
			$response['msg'] = '老密码输入错误';
			$response['rsc'] = C('RESPONSE.FAILED');
			$this->ajaxReturn($response);
		}
		$userSrv->where("user_id = '".$user_id."'")->save(array('password'=>$new_pwd));
		$response['msg'] = '成功';
		$response['rsc'] = C('RESPONSE.SUCCESS');
		$this->ajaxReturn($response);
		
	}
}
